/**
 * Created by Administrator on 2018/1/17.
 */

/**
 * 加载js
 */
function use(path) {
    var head = $("head");
    var isLoad = false;
    var file = "src/" + path + ".js";
    $('head script[role="reload"]').each(function (i, e) {
        if ($(e).attr('src') == file) {
            isLoad = true;
        }
    });
    if (!isLoad) {
        $("<scri" + "pt>" + "</scr" + "ipt>").attr({
            role: 'reload',
            src: file,
            type: 'text/javascript',
            charset: 'utf-8'
        }).appendTo(head);
    }
}
function href(e) {
    return "#/" + e + "/" + rand(1000, 999);
}
/**
 * 获取hash 参数
 * @param key
 * @returns {*}
 */
function get_hash(key) {
    var arr = (location.search || "").replace(/^\?/, '').split("&");
    var params = {};
    for (var i = 0; i < arr.length; i++) {
        var data = arr[i].split("=");
        if (data.length == 2) {
            params[data[0]] = data[1];
        }
    }
    return params[key] ? params[key] : '';
}

//tips window 带回调
function my_tips_(msg, cb) {
    if (!cb) {
        cb = function () {
        };
    }
    var tApp = new Framework7();
    tApp.modal({
        text: '<p class="modal-title" style="margin:0 auto;">提示</p>' +
        '<p class="modal-text" style="margin:.3rem auto 0 auto;">' + msg + '</p>',
        buttons: [{
            text: '确定',
            bold: true,
            onClick: cb
        }]
    });
}

//地址栏清空hash
function clear_hash() {
    history.replaceState(null, '', location.pathname + location.search);
}


use("tool/helper");
use("tool/storage");
use("tool/session");
use("tool/tpl_fill");
use("tool/linxs_tpl");//jquery 扩展
use("tool/phone_code");//发送手机验证码
use("conf/conf");
use("conf/router");
use("event/img");
use("event/plusready");
use("conf/tool_bar");
use("event/page_cb");
use("tool/goods_tool");
use("index/index");
use("seller/conf/router");
/**
 * 支付插件
 */
use("tool/pay");

/***************商家路由  开发时加载 ******************/
use("seller/conf/router");
/***************商家路由  开发时加载  end ******************/